<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <title>新版演示</title>
    <link rel="stylesheet" type="text/css" href="../css/api.css"/>
    <link rel="stylesheet" type="text/css" href="../css/aui.css"/>
    <link rel="stylesheet" type="text/css" href="../css/auislide.css" />
    <link rel="stylesheet" type="text/css" href="../css/style.css"/>
    <style>
        .empty{ text-align: center; padding: 120px 0; }
    </style>
</head>
<body>
  <div id="aui-slide">
    <div id="slidebox" class="aui-slide-wrap">

    </div>
    <div class="aui-slide-page-wrap"></div>
  </div>
  <section class="aui-grid aui-margin-b-15">
      <div class="aui-row" id="fl_list">



      </div>

  </section>

  <div class="fx-box" id="guanggao">


  </div>
  <div class="">

  </div>
</body>
<script type="text/x-dot-template" id="bannertpl">
  {{~ it.data : value : index }}
    <div class="aui-slide-node bg-dark" tapmode onclick="toBanner('{{= value. linkurl }}')">
        <img src="http://www.xv3l.cn/{{= value. picurl }}" />
    </div>
  {{~}}
</script>
<script type="text/x-dot-template" id="flicotpl">
  {{~ it.data : value : index }}
  		<div class="aui-col-xs-3 pt-list" tapmode onclick="toBanner('{{= value. linkurl }}')">
          <i class="aui-iconfont"><img src="http://www.xv3l.cn/{{= value. picurl }}"/></i>
          <div class="aui-grid-label">{{= value. name }}</div>
        </div>

  {{~}}
</script>
<script type="text/x-dot-template" id="guanggaotpl">
  {{~ it.data : value : index }}
  	<div class="fx-box-t">
      <img src="http://www.xv3l.cn/{{= value. picurl }}" style="border-radius:0.5rem;box-shadow:0.2rem 0.2rem 0.4rem rgba(99, 99, 99, 0.61);" tapmode onclick="toBanner('{{= value. linkurl }}')">
    </div>
    <div class="br"></div>
  {{~}}
</script>
<script type="text/javascript" src="../script/api.js"></script>
<script type="text/javascript" src="../script/doT.js"></script>
<script type="text/javascript" src="../script/auipullrefresh.js"></script>
<script type="text/javascript" src="../script/auislide.js"></script>
<script type="text/javascript" src="../script/auilazyload.js" ></script>
<script type="text/javascript">

//alert(localStorage.getItem('fxpic1'));
  var slide = new auiSlide({
      container:document.getElementById("aui-slide"),
      // "width":300,
      "height":120,
      "speed":300,
      "pageShow":true,
      "autoPlay": 5000,
      "pageStyle":'dot',
      "loop":true,
      'dotPosition':'center',
  });
  new auiLazyload({
      errorImage:'../image/error-img.jpg'
  });
  var api_url = localStorage.getItem('api_url');
  apiready = function(){
    api.parseTapmode();

	getNav();
  }

  function imgUrl(img){
    if (img=='img1') {
      api.openWin({
          name: 'h5',
          url: './h5.html',
          pageParam: {
              url: localStorage.getItem('fxurl1')
          }
      });
    }else {
      api.openWin({
          name: 'h5',
          url: './h5.html',
          pageParam: {
              url: img
          }
      });
    }

  }


  //访问轮播地址
  function toBanner(url){

    if (url == '') {

    }else {
      api.openWin({
          name: 'h5',
          url: './h5.html',
          pageParam: {
              url: url
          }
      });
    }
  }


  function openWin(name){
    var time = localStorage.getItem('user_time');
    var user_id = localStorage.getItem('user_id');
    var username = localStorage.getItem('user_name');
    var timestamp = Date.parse(new Date())/1000;
    if (user_id!=0) {
      api.alert({
          title: '请先登录',
          msg: '知道了',
      });
      return;
    }

    if (time > timestamp) {
      api.openWin({
          name: ''+name+'',
          url: ''+name+'.html',
          bounces:false,
          delay: 300
      });
    }else if (time == -1) {
      api.openWin({
          name: ''+name+'',
          url: ''+name+'.html',
          bounces:false,
          delay: 300
      });
    }else if (time < timestamp) {
      alert('到期啦~官人先开个VIP哟');
      api.openWin({
          name: 'open_vip_win',
          url: './open_vip_win.html',
      });
    }

  }



  //幻灯轮播图
  function banNer(){
    var slide = new auiSlide({
        container:document.getElementById("aui-slide"),
        // "width":300,
        "height":150,
        "speed":300,
        "pageShow":true,
        "autoPlay": 5000,
        "pageStyle":'dot',
        "loop":true,
        'dotPosition':'center',
    });
  }
//图标获取
  function getNav(){
    var flid = $api.byId('fl_list');
    var fltpl = $api.byId('flicotpl');
	var bannerid = $api.byId('slidebox');
    var bannertpl = $api.byId('bannertpl');

    var guanggaoid = $api.byId('guanggao');
    var guanggaotpl = $api.byId('guanggaotpl');
    api.ajax({
        url: api_url+'/app/nav/fl',
        method: 'get',
    },function(ret, err){
        if (ret) {
          //渲染模板
          var pagefn = doT.template(fltpl.text);
          flid.innerHTML = pagefn(ret.tu);
          var pagefn = doT.template(bannertpl.text);
          bannerid.innerHTML = pagefn(ret.banner);
          var pagefn = doT.template(guanggaotpl.text);
          guanggaoid.innerHTML = pagefn(ret.guanggao);
           banNer();
//        alert( JSON.stringify( ret.banner ) );


        } else {
            alert( '网络错误' );
            api.hideProgress();
        }
    });
  }
</script>

</html>
